package com.bike.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.http.HttpResponse;

import com.alibaba.fastjson.JSONObject;
//import com.taobao.api.ApiException;
//import com.taobao.api.DefaultTaobaoClient;
//import com.taobao.api.TaobaoClient;
//import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
//import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;


public class AliDaYuSmsUtil {

	public static final String  appKey = "23595679";  //应用列表中可以找到
    public static final String appSecret = "270cc3e15c101fe129f665b70ed0b618";//secret
    public static final String url="http://gw.api.taobao.com/router/rest";   //网址
    public static final String smsTemplateCode ="SMS_37675266";    //模板ID 
    public static final String smsFreeSignName ="零客单车";    //短信签名 
 
    
    //phoneNumber手机号码    number:6位数的验证码
    public static void sendSmsAliMessage(String phoneNumber,String number) {        
//        try {
//            TaobaoClient client = new DefaultTaobaoClient(url, appKey,appSecret);
//            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
//            req.setExtend( "extend" );
//            req.setSmsType( "normal" );  //短信类型
//            req.setSmsFreeSignName( smsFreeSignName);
//            req.setSmsParamString( "{code:'"+number+"'}" );
//            req.setRecNum( phoneNumber);
//            req.setSmsTemplateCode( smsTemplateCode );
//            AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
//            System.out.println(rsp.getBody());
//        } catch (ApiException e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }

    }
    
    public static void main(String[] args) {
    	
    	sendSmsAliMessage("13126506185", "156684");
    	
    	
	}
    public static void nott(){
    	String host = "http://sms.market.alicloudapi.com";
        String path = "/singleSendSms";
        String method = "GET";
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("Authorization", "3e5affa9373f461caba879a0289ec671");
        Map<String, String> querys = new HashMap<String, String>();
        
        JSONObject paramStr=new JSONObject();
        paramStr.put("code", "674567");
        System.out.println(paramStr.toJSONString().length());
        querys.put("ParamString", paramStr.toJSONString());
        querys.put("RecNum", "13126506185");//手机号  多个 逗号隔开
        querys.put("SignName", "零客单车");//签名名称
        querys.put("TemplateCode", "SMS_37675266");//模板CODE

        try {
            /**
            * 重要提示如下:
            * HttpUtils请从
            * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
            * 下载
            *
            * 相应的依赖请参照
            * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
            */
            HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
            System.out.println(response.toString());
            //获取response的body
            //System.out.println(EntityUtils.toString(response.getEntity()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
	
}
